/**
 * 무게를 저장하는 클래스로 기본단위는 그램(g)이다.
 * 
 * @author sppurple
 * 
 */

public class Mass {
	private double mass;

	//
	// Constructor
	//
	Mass() {
		this.mass = 0;
	}

	Mass(double mass) {
		this.mass = mass;
	}

	/**
	 * 지정된 단위로 질량을 설정. 만약 단위가 잘못되면 -1로 질량 설정.
	 * 
	 * @param mass
	 * @param measure
	 *            단위("g" : 그램, "kg" : 킬로그램, "t" : 톤)
	 */
	Mass(double mass, String measure) {
		if (measure == null)
			this.mass = -1;
		else if (measure.equals("g")) {
			this.mass = mass;
		} else if (measure.equals("kg")) {
			this.mass = mass * 1000;
		} else if (measure.equals("t")) {
			this.mass = mass * 10000000;
		} else
			this.mass = -1;
	}

	//
	// getters and setters
	//
	public double getMassPerGram() {
		return mass;
	}

	public void setMassPerGram(double mass) {
		this.mass = mass;
	}

	public double getMassPerKilogram() {
		return mass / 1000;
	}

	public void setMassPerKilogram(double mass) {
		this.mass = mass * 1000;
	}

	public double getMassPerTon() {
		return mass / 1000000;
	}

	public void setMassPerTon(double mass) {
		this.mass = mass * 1000000;
	}

}
